const mock = require('mockjs') //   这个是引用库

let Result = {
    code: 200,
    msg: '操作成功',
    data: null
}

// mock.mock的目的就是拦截目的，这样axios的访问，就可以被拦截了。但是一定要记得， 在main.js当中引入，只有引入了才生效。
// 获取用户菜单以及权限接口
mock.mock('/menu', 'post', (req) => {
    let menu;
    console.log('请求体',req.body)
    if (JSON.parse(req.body).roleName === "超级管理员" ||JSON.parse(req.body).roleName === "管理员" ){
         menu = [
            {
                name: 'itemManagement',
                label: '项目管理',
                icon: 's-cooperation',
                component: '@/views/ItemManagement.vue',
                path: '/itemManagement',
                url:'ItemManagement',
                children:null
            },
            {
                name: 'staffManagement',
                label: '用户管理',
                icon: 'user-solid',
                path: '/staffManagement',
                component: '@/views/StaffManagement.vue',
                url:'StaffManagement',
                children:null
            },
            {
                 name: 'deptManagement',
                 label: '部门管理',
                 icon: 's-management',
                 path: '/deptManagement',
                 component: '@/views/DeptManagement.vue',
                 url:'DeptManagement',
                 children:null
            },
            {
                 name: 'roleManagement',
                 label: '角色管理',
                 icon: 's-grid',
                 path: '/roleManagement',
                 component: '@/views/RoleManagement.vue',
                 url:'RoleManagement',
                 children:null
            },
            {
                 name: 'postManagement',
                 label: '岗位管理',
                 icon: 's-custom',
                 path: '/postManagement',
                 component: '@/views/PostManagement.vue',
                 url:'PostManagement',
                 children:null
            }
        ]
    } else {
        menu = [
            {
                name: 'itemManagement',
                label: '项目管理',
                icon: 's-cooperation',
                component: '@/views/ItemManagement.vue',
                path: '/itemManagement',
                url:'ItemManagement',
                children:null
            }
               ]
           }

    Result.data = {
        menu: menu
    }

    return Result
})